/** ###################################################################
**     Filename  : linear_ccd.h
**     Project   : ccd2
**     Processor : MCF52255CAF80
**     Version   : Driver 01.00
**     Compiler  : CodeWarrior MCF C Compiler
**     Arthor	 : Yumi Chan, Cindy Yu, Ryan Cheung
**     Abstract  :
**         
**     Settings  :
**     Contents  :
**         No public methods
**
** ###################################################################*/

#ifndef __LINEAR_CCD_H
#define __LINEAR_CCD_H


/* Include */
#include "support_common.h"
#include "CCD_pixel.h"
#include "CCD_CLK.h"
#include "CCD_SI.h"
#include "CCD2_pixel.h"
#include "CCD2_CLK.h"
#include "CCD2_SI.h"


/* Define */
#define	USE_TWO_LINEAR_CCD		TRUE

#define	MAX_NUM_OF_CCD			2
#define	CCD1					0
#define	CCD2					1
#define	CCD_RESOLUTION			128
#define UNUSED_PIXEL_1SIDE		4
//#define UNUSED_PIXEL			12
#define IMAGE_RESOLUTION		CCD_RESOLUTION - (2*UNUSED_PIXEL_1SIDE)

#define	BLACK		1
#define	WHITE		0

#define	NOT_FIND_LEFT_EDGE		-1024
#define	NOT_FIND_RIGHT_EDGE		1024
#define MAX_NO_OF_EDGE			3
#define	LEFT					0
#define	RIGHT					1
#define	TOTAL					2


/* Private typedef */
typedef struct LINEAR_CCD 
{
  bool image[IMAGE_RESOLUTION];
  short threshold;
  short left_edge_pos[2];
  short right_edge_pos[2];
  short trackWidth;
  short trackCenter;
  uint8 no_of_black[2];
} LINEAR_CCD;


/* Variables Declaration */
extern LINEAR_CCD ccd[MAX_NUM_OF_CCD];

#if (USE_TWO_LINEAR_CCD)
extern float trackWidth_ratio;
#endif


/* Private Method Declaration */
void collectCCDImage(void);
void findTrackWidth(void);

#endif